package com.phpxiu.app.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;

import com.phpxiu.app.adapter.holder.C2CChatMsgViewHolder;
import com.phpxiu.app.kkylive.R;
import com.phpxiu.app.model.MySelfInfo;
import com.phpxiu.app.model.msg.C2CMsg;

import java.util.List;

/**
 * 私信聊天界面adapter
 */
public class C2CChatListAdapter extends BaseAdapter<C2CMsg> {
    private final String TAG = "C2CChatListAdapter";
    private String mAvatar;
    public C2CChatListAdapter(Context context, List<C2CMsg> data,String avatar) {
        super(context, data);
        mAvatar=avatar;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        C2CChatMsgViewHolder holder=null;
        C2CMsg msg=data.get(position);
        if(convertView==null){
            convertView=mInflater.inflate(R.layout.c3c_chat_list_item_view,null);
            holder=new C2CChatMsgViewHolder(convertView);
            holder.friendHeadView.setImageURI(Uri.parse(mAvatar));
            holder.myHeadView.setImageURI(Uri.parse(MySelfInfo.getInstance().getAvatar()));
            convertView.setTag(holder);
        }
        holder=(C2CChatMsgViewHolder)convertView.getTag();
        holder.showMsg(msg);
        return convertView;
    }
}
